import request from "./../utils/request.js";

/**
 * 接接口的第一步
 * 小程序用户登录
 * @param data object 小程序用户登陆信息
 */
export function login(data) {
  return request.get("/wxapi.php/public/login",data);
}

export function index() {
  return request.get("/"); 
}




export function distanceFind(data) {
  return request.post("/wxapi.php/service/distanceFind", data);
}
/**
 * 获取轮播图
 */
export function getPublic(data){
  return request.get("/wxapi.php", data, { noAuth: true });
}

export function storeGoods(data) {
  return request.get("/store/goods", data, { noAuth: true });
}

export function memberUserinfo(data) {
  return request.post("/wxapi.php/member/user_info", data, { noAuth: true });
}

export function userLogin(data) {
  return request.get("/wxapi.php/public/login", data, { noAuth: true });
}

export function storeDetail(data) {
  return request.get("/wxapi.php/store/goods_detail", data, { noAuth: true});
}

export function storeIndex(data) {
  return request.get("/wxapi.php/store/index", data, { noAuth: true });
}

export function storeCanbuy(data) {
  return request.get("/wxapi.php/store/canbuy",  data, { noAuth: true });
}
/**
 * 根据城市和车型获取经销商
 */
export function getCityCartypeDealerList(data) {
  return request.post("/wxapi.php/service/getCityCartypeDealerList", data);
}

export function getServiceData (data={}) {
  return request.get("/wxapi.php/service/station",data);
}

export function getUserSign(data) {
  return request.get("/wxapi.php/forum/get_user_sign",
    data, { noAuth: true });
}

export function forumSignin(data) {
  return request.post("/wxapi.php/forum/signin", data);
}


export function actionPost(data) {
  return request.post("/wxapi.php/actions/join",
    data, { noAuth: true});
}

export function memverUser(data) {
  return request.get("/wxapi.php/member/user", data, { noAuth: true });
}

/**
 * 获取省份
 */
export function getProv(data) {
  return request.get("/wxapi.php/forum/get_prov",
    data, { noAuth: true });
}

// 授权手机号码 注册
export function authRegister(data) {
  return request.post("/wxapi.php/user/auth_register", data, { noAuth: true });
}

// 手机号码+验证码 注册
export function register(data) {
  return request.post("/wxapi.php/user/register", data, { noAuth: true });
}
//forum/get_prov

/**
 * 获取会员卡号
 */
export function userVipcard(data) {
  return request.get("/wxapi.php/user/vipcard",
    data, { noAuth: true });
}

/**
 * 发送验证码
 */
export function sendCode(data) {
  return new Promise( (resolve) => {
    request.post("/wxapi.php/user/sendCaptcha", data, { noAuth: true}).then(res => {
      resolve(res);
    })
  })
}

/**
 * 已兑换商品
 */
export function userMyorder(data) {
  return request.get("/wxapi.php/user/myorder",
    data, { noAuth: true });
}

/**
 * 获取用户认证时的车型数据
 */
export function get_esncode(data={}) {
  return request.get("/wxapi.php/user/get_esncode", data, { noAuth: true });
}

/**
 * 用户认证接口 post 三个参数
 */
export function certified(data={}) {
  return request.post("/wxapi.php/user/certified", data,  { noAuth: true });
}

/**
 * 判断用户是否认证 get openid
 */
export function checkcertified(data={}) {
  return request.get("/wxapi.php/user/checkcertified", data,  { noAuth: true });
}
// 获取活动列表以及获取活动详情
export function actionsIndex(data) {
  return request.get("/wxapi.php/actions/index",
    data, { noAuth: true });
}

// 根据openid获取用户信息
export function getuserInfo(data) {
  return request.post("/wxapi.php/user/get_userinfo",  data, { noAuth: true });
}

// 根据openid获取消息列表
export function getMessage(data) {
  return request.get("/wxapi.php/user/message", data, { noAuth: true });
}

// 购买
export function buy(data) {
  return request.post('/wxapi.php/order/buy', data , { noAuth: true});
}

// 分享
export function share(data) {
  return request.post('/wxapi.php/user/share', data, { noAuth: true});
}